package com.liqing.movecomment.controller;
import com.github.pagehelper.PageInfo;
import com.liqing.movecomment.entity.Actor;
import com.liqing.movecomment.entity.Tag;
import com.liqing.movecomment.service.ActorService;
import io.swagger.annotations.Api;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
 * (Actor)表控制层
 *
 * @author makejava
 * @since 2023-05-08 02:16:16
 */
import com.liqing.movecomment.annotation.ResponseResult;

import java.util.List;

@ResponseResult
@Api(tags ="演员管理")
@RequestMapping("actor")
public class ActorController {
    /**
     * 服务对象
     */
    @Resource
    private ActorService actorService;

    /**
     * 分页查询
     *
     * @param page 页码
     * @param size  页长
     * @return 查询结果
     */
    @GetMapping
    public PageInfo<Actor> queryAll(Integer page,Integer size) {
        return this.actorService.queryAll(page,size);
    }

    /**
     * 查询全部
     * @return
     */
    @GetMapping("/list")
    public List<Actor> list(){
        return actorService.list();
    }


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */

    @GetMapping("{id}")
    public Actor queryById(@PathVariable("id") Integer id) {
        return this.actorService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param actor 实体
     * @return 新增结果
     */
    @PostMapping
    public Actor add(@RequestBody Actor actor) {
        return this.actorService.insert(actor);
    }

    /**
     * 编辑数据
     *
     * @param actor 实体
     * @return 编辑结果
     */
    @PutMapping
    public Actor edit(Actor actor) {
        return this.actorService.update(actor);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Boolean deleteById(Integer id) {
        return this.actorService.deleteById(id);
    }

}

